function setValue (val) {
  if ([undefined, null].includes(val)) {
    return ''
  }
  return val
}

export function formatter (data, labelKey, valueKey) {
  let res = []
  if (data instanceof Array && data.length) {
    data.forEach(item => {
      res.push({
        label: setValue(item[labelKey]),
        value: setValue(item[valueKey]),
      })
    })
  }
  return res
}